package com.crr.apis;

import com.crr.entities.PayDTO;
import com.crr.ret.ResultData;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;


import java.util.List;

/**
 * fallback对全局方法走统一的服务降级
 */

//@FeignClient(value = "cloud-payment-service")
@FeignClient(value = "cloud-gateway")
public interface PayFeignApi {
    /**
     * 支付相关流水服务
     *
     * @param payDTO
     * @return
     */
    @PostMapping("/pay/add")
    public ResultData addPay(@RequestBody PayDTO payDTO);

    @DeleteMapping("/pay/delete/{id}")
    public ResultData<Integer> deletePay(@PathVariable("id") Integer id);

    @PutMapping("/pay/update")
    public ResultData<String> updatePay(@RequestBody PayDTO payDTO);


    @GetMapping("/pay/get/{id}")
    public ResultData<PayDTO> getById(@PathVariable("id") Integer id);

    @GetMapping("/pay/getAll")
    public ResultData<List> getAll();

    /**
     * 负载均衡演示
     *
     * @return
     */
    @GetMapping("/pay/info")
    public String mylb();

    /**
     * 熔断测试
     *
     * @param id
     * @return
     */
    @GetMapping("/pay/circuit/{id}")
    public ResultData<String> myCircuit(@PathVariable("id") Integer id);

    /**
     * 隔离bulkhead
     *
     * @param id
     * @return
     */
    @GetMapping("/pay/bulkhead/{id}")
    public ResultData<String> myBulkHead(@PathVariable("id") Integer id);

    @GetMapping("/pay/rateLimit/{id}")
    public ResultData<String> myRateLimit(@PathVariable("id") Integer id);

    @GetMapping("/pay/micrometer/{id}")
    public String myMicrometer(@PathVariable("id") Integer id);

    @GetMapping("/pay/gateway/get/{id}")
    public ResultData<PayDTO> getById2(@PathVariable("id") Integer id);

    @GetMapping("/pay/gateway/get/info")
    public ResultData<String> getInfo();
}
